home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / examples / hism_1_0 / part01
Encoding:
Internet Message Format  |  1990-03-17  |  53.0 KB

  1. Path: xanth!cs.odu.edu!Amiga-Request
  2. From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v90i115: HISM 1.0 - incremental storage manager for modula-2, Part01/01
  5. Message-ID: <11862@xanth.cs.odu.edu>
  6. Date: 17 Mar 90 20:33:35 GMT
  7. Sender: news@cs.odu.edu
  8. Reply-To: <dan-hankins@cup.portal.com>
  9. Lines: 1901
  10. Approved: tadguy@cs.odu.edu (Tad Guy)
  11. X-Mail-Submissions-To: Amiga@cs.odu.edu
  12. X-Post-Discussions-To: comp.sys.amiga
  13.  
  14. Submitted-by: <dan-hankins@cup.portal.com>
  15. Posting-number: Volume 90, Issue 115
  16. Archive-name: examples/hism-1.0/part01
  17.  
  18.      This set of modules constitutes a storage manager with garbage
  19. collection for Modula-2 programs.  It is written in TDI Modula-2 for the
  20. Amiga, but should be easily portable to other implementations and
  21. architectures.
  22.  
  23. #!/bin/sh
  24. # This is a shell archive.  Remove anything before this line, then unpack
  25. # it by saving it into a file and typing "sh file".  To overwrite existing
  26. # files, type "sh file -c".  You can also feed this as standard input via
  27. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  28. # will see the following message at the end:
  29. #        "End of archive 1 (of 1)."
  30. # Contents:  Build.Rexx DynItem.def DynItem.mod DynItemList.def
  31. #   DynItemList.mod DynTest.mod DynamicItem.def DynamicItem.mod
  32. #   FreeHandle.def FreeHandle.mod HandleCollection.def
  33. #   HandleCollection.mod README Storage.def Storage.mod WordAlign.def
  34. #   WordAlign.mod
  35. # Wrapped by tadguy@xanth on Sat Mar 17 15:33:16 1990
  36. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  37. if test -f 'Build.Rexx' -a "${1}" != "-c" ; then 
  38.   echo shar: Will not clobber existing file \"'Build.Rexx'\"
  39. else
  40. echo shar: Extracting \"'Build.Rexx'\" \(833 characters\)
  41. sed "s/^X//" >'Build.Rexx' <<'END_OF_FILE'
  42. X/**/
  43. X
  44. Xaddress command
  45. Xcall erasefiles
  46. Xcall addfiles
  47. Xcall compilefiles
  48. Xcall linkfile
  49. X'dir *.er*'
  50. Xexit 0
  51. X
  52. Xerasefiles:
  53. X  'delete *.sym *.lnk *.er*'
  54. Xreturn
  55. X
  56. Xaddfiles:
  57. X  files = 0
  58. X  call addfile 'DynItemList.def'
  59. X  call addfile 'DynamicItem.def'
  60. X  call addfile 'DynItem.def'
  61. X  call addfile 'HandleCollection.def'
  62. X  call addfile 'FreeHandle.def'
  63. X  call addfile 'WordAlign.def'
  64. X  call addfile 'Storage.def'
  65. X
  66. X  call addfile 'DynItemList'
  67. X  call addfile 'DynamicItem'
  68. X  call addfile 'DynItem'
  69. X  call addfile 'HandleCollection'
  70. X  call addfile 'FreeHandle'
  71. X  call addfile 'WordAlign'
  72. X  call addfile 'Storage'
  73. X  call addfile 'DynTest'
  74. Xreturn
  75. X
  76. Xaddfile:
  77. X  parse arg filename
  78. X  files = files + 1
  79. X  infile.files = filename
  80. Xreturn
  81. X
  82. Xcompilefiles:
  83. X  do index = 1 to files
  84. X    'modula' infile.index
  85. X  end
  86. Xreturn
  87. X
  88. X
  89. Xlinkfile:
  90. X  'link' infile.index
  91. Xreturn
  92. END_OF_FILE
  93. if test 833 -ne `wc -c <'Build.Rexx'`; then
  94.     echo shar: \"'Build.Rexx'\" unpacked with wrong size!
  95. fi
  96. # end of 'Build.Rexx'
  97. fi
  98. if test -f 'DynItem.def' -a "${1}" != "-c" ; then 
  99.   echo shar: Will not clobber existing file \"'DynItem.def'\"
  100. else
  101. echo shar: Extracting \"'DynItem.def'\" \(1462 characters\)
  102. sed "s/^X//" >'DynItem.def' <<'END_OF_FILE'
  103. XDEFINITION MODULE DynItem;
  104. X
  105. X(* Product: Incremental Storage Manager
  106. X
  107. X   Version: 1.0
  108. X
  109. X   Author:
  110. X        Daniel B. Hankins
  111. X        143 Montgomery Street
  112. X        Poughkeepsie, NY 12601
  113. X        dan-hankins@cup.portal.com
  114. X
  115. X   Creation Date: 1989
  116. X
  117. X   Release  Date: November 21, 1989
  118. X
  119. X   Notice of Intellectual Property:
  120. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  121. X   this program and all its parts in the public domain, under the definitions
  122. X   and restrictions of United States law.
  123. X
  124. X   History of Revisions:
  125. X        None yet.
  126. X*)
  127. X
  128. XFROM SYSTEM IMPORT ADDRESS;
  129. X
  130. XIMPORT DynamicItem;
  131. XIMPORT DynItemList;
  132. X
  133. XTYPE
  134. X  Object;
  135. X
  136. XPROCEDURE New(Size: LONGCARD; TermIt: DynamicItem.TermProc): Object;
  137. X
  138. XPROCEDURE Init(DObject: Object; InitIt: DynamicItem.InitProc);
  139. X
  140. XPROCEDURE SetHandle(DObject: Object; Handle: DynamicItem.Object);
  141. X
  142. XPROCEDURE Dispose(DObject: Object): BOOLEAN;
  143. X
  144. XPROCEDURE Kill(DObject: Object);
  145. X
  146. XPROCEDURE Ref(DObject: Object);
  147. X
  148. XPROCEDURE Access(DObject: Object): ADDRESS;
  149. X
  150. XPROCEDURE GetList(DObject: Object): DynItemList.Object;
  151. X
  152. XPROCEDURE Percolate(DObject: Object);
  153. X
  154. XPROCEDURE LinkAfter(DObjectNew, DObjectOld: Object);
  155. X
  156. XPROCEDURE Unlink(DObject: Object);
  157. X
  158. XPROCEDURE GetPrev(DObject: Object): Object;
  159. X
  160. XPROCEDURE GetNext(DObject: Object): Object;
  161. X
  162. XPROCEDURE MoveDown(DObject: Object): Object;
  163. X
  164. XPROCEDURE NextAddr(DObject: Object): ADDRESS;
  165. X
  166. XPROCEDURE NilObject(): Object;
  167. X
  168. XPROCEDURE Nil(DObject: Object): BOOLEAN;
  169. X
  170. XEND DynItem.
  171. END_OF_FILE
  172. if test 1462 -ne `wc -c <'DynItem.def'`; then
  173.     echo shar: \"'DynItem.def'\" unpacked with wrong size!
  174. fi
  175. # end of 'DynItem.def'
  176. fi
  177. if test -f 'DynItem.mod' -a "${1}" != "-c" ; then 
  178.   echo shar: Will not clobber existing file \"'DynItem.mod'\"
  179. else
  180. echo shar: Extracting \"'DynItem.mod'\" \(5464 characters\)
  181. sed "s/^X//" >'DynItem.mod' <<'END_OF_FILE'
  182. XIMPLEMENTATION MODULE DynItem;
  183. X
  184. X(* Product: Incremental Storage Manager
  185. X
  186. X   Version: 1.0
  187. X
  188. X   Author:
  189. X        Daniel B. Hankins
  190. X        143 Montgomery Street
  191. X        Poughkeepsie, NY 12601
  192. X        dan-hankins@cup.portal.com
  193. X
  194. X   Creation Date: 1989
  195. X
  196. X   Release  Date: November 21, 1989
  197. X
  198. X   Notice of Intellectual Property:
  199. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  200. X   this program and all its parts in the public domain, under the definitions
  201. X   and restrictions of United States law.
  202. X
  203. X   History of Revisions:
  204. X        None yet.
  205. X*)
  206. X
  207. XFROM SYSTEM      IMPORT ADDRESS, TSIZE, WORD;
  208. XFROM WordAlign   IMPORT WordAlign;
  209. X
  210. XIMPORT DynamicItem;
  211. XIMPORT DynItemList;
  212. X
  213. XTYPE
  214. X  Object  = POINTER TO Item;
  215. X  WordPtr = POINTER TO WORD;
  216. X
  217. X  Item = RECORD
  218. X           NextLower, NextHigher: Object;
  219. X           Size, RefCount:        LONGCARD;
  220. X           Term:                  DynamicItem.TermProc;
  221. X           List:                  DynItemList.Object;
  222. X           Handle:                DynamicItem.Object;
  223. X         END;
  224. X
  225. XVAR
  226. X  ItemTypeSize: LONGCARD;
  227. X
  228. X
  229. XPROCEDURE New(Size: LONGCARD; TermIt: DynamicItem.TermProc): Object;
  230. XVAR
  231. X  NewObject: Object;
  232. X  TotalSize: LONGCARD;
  233. X  List:      DynItemList.Object;
  234. XBEGIN
  235. X(* New(Size, Object) <-
  236. X     WordAlign(Size, Size),
  237. X     Plus(Size, ItemTypeSize, TotalSize),
  238. X     DynItemList.GetListWithSpace(TotalSize, List),
  239. X     New2(TotalSize, List, Object).
  240. X   New2(TotalSize, List, Object) <-
  241. X     DynItemList.Nil(List),
  242. X     SetValue(Object, NIL).
  243. X   New2(TotalSize, List, Object) <-
  244. X     DynItemList.GetChunk(List, TotalSize, NewObject),
  245. X     SetValue(NewObject^.Size,     TotalSize),
  246. X     SetValue(NewObject^.RefCount, 1),
  247. X     SetValue(NewObject^.List,     List),
  248. X     SetValue(NewObject^.Handle,   NIL),
  249. X     DynItemList.LinkItem(List, NewObject),
  250. X     SetValue(Object, NewObject).
  251. X*)
  252. X  Size      := WordAlign(Size);
  253. X  TotalSize := Size + ItemTypeSize;
  254. X  List      := DynItemList.GetListWithSpace(TotalSize);
  255. X
  256. X  IF DynItemList.Nil(List) THEN
  257. X    RETURN(NIL);
  258. X  END;
  259. X
  260. X  NewObject           := DynItemList.GetChunk(List, TotalSize);
  261. X  NewObject^.Size     := TotalSize;
  262. X  NewObject^.RefCount := 1;
  263. X  NewObject^.List     := List;
  264. X  NewObject^.Term     := TermIt;
  265. X  DynItemList.LinkItem(List, NewObject);
  266. X
  267. X  RETURN NewObject;
  268. XEND New;
  269. X
  270. X
  271. XPROCEDURE Init(DObject: Object; InitIt: DynamicItem.InitProc);
  272. XBEGIN
  273. X  InitIt(Access(DObject));
  274. XEND Init;
  275. X
  276. X
  277. XPROCEDURE SetHandle(DObject: Object; Handle: DynamicItem.Object);
  278. XBEGIN
  279. X  DObject^.Handle := Handle;
  280. XEND SetHandle;
  281. X
  282. X
  283. XPROCEDURE Dispose(DObject: Object): BOOLEAN;
  284. XBEGIN
  285. X  DObject^.RefCount := DObject^.RefCount - 1;
  286. X  IF DObject^.RefCount = 0 THEN
  287. X    DObject^.Term(Access(DObject));
  288. X    Kill(DObject);
  289. X    RETURN TRUE;
  290. X  END;
  291. X  RETURN FALSE;
  292. XEND Dispose;
  293. X
  294. X
  295. XPROCEDURE Kill(DObject: Object);
  296. XBEGIN
  297. X  DynItemList.UnlinkItem(DObject^.List, DObject);
  298. XEND Kill;
  299. X
  300. X
  301. XPROCEDURE Ref(DObject: Object);
  302. XBEGIN
  303. X  DObject^.RefCount := DObject^.RefCount + 1;
  304. XEND Ref;
  305. X
  306. X
  307. XPROCEDURE Access(DObject: Object): ADDRESS;
  308. XBEGIN
  309. X  RETURN ADDRESS(LONGCARD(DObject) + ItemTypeSize);
  310. XEND Access;
  311. X
  312. X
  313. XPROCEDURE GetList(DObject: Object): DynItemList.Object;
  314. XBEGIN
  315. X  RETURN DObject^.List;
  316. XEND GetList;
  317. X
  318. X
  319. XPROCEDURE Percolate(DObject: Object);
  320. XBEGIN
  321. X  DynItemList.Percolate(DObject^.List);
  322. XEND Percolate;
  323. X
  324. X
  325. XPROCEDURE LinkAfter(DObjectNew, DObjectOld: Object);
  326. XBEGIN
  327. XIF DObjectOld <> NIL THEN
  328. X  DObjectNew^.NextLower  := DObjectOld;
  329. X  DObjectNew^.NextHigher := DObjectOld^.NextHigher;
  330. X  DObjectNew^.NextLower^.NextHigher := DObjectNew;
  331. X  IF DObjectNew^.NextHigher <> NIL THEN
  332. X    DObjectNew^.NextHigher^.NextLower := DObjectNew;
  333. X  END;
  334. XELSE
  335. X  DObjectNew^.NextLower := NIL;
  336. X  DObjectNew^.NextHigher := NIL;
  337. XEND;
  338. XEND LinkAfter;
  339. X
  340. X
  341. XPROCEDURE Unlink(DObject: Object);
  342. XBEGIN
  343. X  IF DObject^.NextLower <> NIL THEN
  344. X    DObject^.NextLower^.NextHigher := DObject^.NextHigher;
  345. X  END;
  346. X  IF DObject^.NextHigher <> NIL THEN
  347. X    DObject^.NextHigher^.NextLower := DObject^.NextLower;
  348. X  END;
  349. XEND Unlink;
  350. X
  351. X
  352. XPROCEDURE GetPrev(DObject: Object): Object;
  353. XBEGIN
  354. X  RETURN DObject^.NextLower;
  355. XEND GetPrev;
  356. X
  357. X
  358. XPROCEDURE GetNext(DObject: Object): Object;
  359. XBEGIN
  360. X  RETURN DObject^.NextHigher;
  361. XEND GetNext;
  362. X
  363. X
  364. XPROCEDURE MoveDown(DObject: Object): Object;
  365. X VAR
  366. X  DestinationAddr: ADDRESS;
  367. X  SourceWord, DestinationWord: WordPtr;
  368. X  BytesToMove: LONGCARD;
  369. XBEGIN
  370. X  IF DObject^.NextLower = NIL THEN
  371. X    DestinationAddr := DynItemList.NextAddr(DObject^.List);
  372. X  ELSE
  373. X    DestinationAddr := NextAddr(DObject^.NextLower);
  374. X  END;
  375. X
  376. X  DynamicItem.Set(DObject^.Handle, DestinationAddr);
  377. X
  378. X  BytesToMove := DObject^.Size;
  379. X  SourceWord := ADDRESS(DObject);
  380. X  DestinationWord := DestinationAddr;
  381. X
  382. X  LOOP
  383. X    IF BytesToMove = 0 THEN
  384. X      EXIT;
  385. X    END;
  386. X    DestinationWord^ := SourceWord^;
  387. X    DestinationWord  := ADDRESS(LONGCARD(DestinationWord) + 2);
  388. X    SourceWord       := ADDRESS(LONGCARD(SourceWord) + 2);
  389. X    BytesToMove      := BytesToMove - 2;
  390. X  END;
  391. X
  392. X  DObject := DestinationAddr;
  393. X
  394. X  IF DObject^.NextLower <> NIL THEN
  395. X    DObject^.NextLower^.NextHigher := DObject;
  396. X  END;
  397. X
  398. X  IF DObject^.NextHigher <> NIL THEN
  399. X    DObject^.NextHigher^.NextLower := DObject;
  400. X  END;
  401. X
  402. X  RETURN Object(DestinationAddr);
  403. XEND MoveDown;
  404. X
  405. X
  406. XPROCEDURE NextAddr(DObject: Object): ADDRESS;
  407. XBEGIN
  408. X  RETURN ADDRESS(LONGCARD(DObject) + DObject^.Size);
  409. XEND NextAddr;
  410. X
  411. X
  412. XPROCEDURE NilObject(): Object;
  413. XBEGIN
  414. X  RETURN NIL;
  415. XEND NilObject;
  416. X
  417. X
  418. XPROCEDURE Nil(DObject: Object): BOOLEAN;
  419. XBEGIN
  420. X  RETURN (DObject = NIL);
  421. XEND Nil;
  422. X
  423. X
  424. XBEGIN
  425. X  ItemTypeSize := WordAlign(TSIZE(Item));
  426. XEND DynItem.
  427. END_OF_FILE
  428. if test 5464 -ne `wc -c <'DynItem.mod'`; then
  429.     echo shar: \"'DynItem.mod'\" unpacked with wrong size!
  430. fi
  431. # end of 'DynItem.mod'
  432. fi
  433. if test -f 'DynItemList.def' -a "${1}" != "-c" ; then 
  434.   echo shar: Will not clobber existing file \"'DynItemList.def'\"
  435. else
  436. echo shar: Extracting \"'DynItemList.def'\" \(986 characters\)
  437. sed "s/^X//" >'DynItemList.def' <<'END_OF_FILE'
  438. XDEFINITION MODULE DynItemList;
  439. X
  440. X(* Product: Incremental Storage Manager
  441. X
  442. X   Version: 1.0
  443. X
  444. X   Author:
  445. X        Daniel B. Hankins
  446. X        143 Montgomery Street
  447. X        Poughkeepsie, NY 12601
  448. X        dan-hankins@cup.portal.com
  449. X
  450. X   Creation Date: 1989
  451. X
  452. X   Release  Date: November 21, 1989
  453. X
  454. X   Notice of Intellectual Property:
  455. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  456. X   this program and all its parts in the public domain, under the definitions
  457. X   and restrictions of United States law.
  458. X
  459. X   History of Revisions:
  460. X        None yet.
  461. X*)
  462. X
  463. XFROM SYSTEM IMPORT ADDRESS;
  464. X
  465. XTYPE
  466. X  Object;
  467. X
  468. XPROCEDURE GetListWithSpace(Size: LONGCARD): Object;
  469. X
  470. XPROCEDURE GetChunk(List: Object; Size: LONGCARD): ADDRESS;
  471. X
  472. XPROCEDURE LinkItem(List: Object; Item: ADDRESS);
  473. X
  474. XPROCEDURE Percolate(List: Object);
  475. X
  476. XPROCEDURE UnlinkItem(List: Object; Item: ADDRESS);
  477. X
  478. XPROCEDURE NextAddr(List: Object): ADDRESS;
  479. X
  480. XPROCEDURE DisposeAll();
  481. X
  482. XPROCEDURE Nil(List: Object): BOOLEAN;
  483. X
  484. XEND DynItemList.
  485. END_OF_FILE
  486. if test 986 -ne `wc -c <'DynItemList.def'`; then
  487.     echo shar: \"'DynItemList.def'\" unpacked with wrong size!
  488. fi
  489. # end of 'DynItemList.def'
  490. fi
  491. if test -f 'DynItemList.mod' -a "${1}" != "-c" ; then 
  492.   echo shar: Will not clobber existing file \"'DynItemList.mod'\"
  493. else
  494. echo shar: Extracting \"'DynItemList.mod'\" \(6556 characters\)
  495. sed "s/^X//" >'DynItemList.mod' <<'END_OF_FILE'
  496. XIMPLEMENTATION MODULE DynItemList;
  497. X
  498. X(* Product: Incremental Storage Manager
  499. X
  500. X   Version: 1.0
  501. X
  502. X   Author:
  503. X        Daniel B. Hankins
  504. X        143 Montgomery Street
  505. X        Poughkeepsie, NY 12601
  506. X        dan-hankins@cup.portal.com
  507. X
  508. X   Creation Date: 1989
  509. X
  510. X   Release  Date: November 21, 1989
  511. X
  512. X   Notice of Intellectual Property:
  513. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  514. X   this program and all its parts in the public domain, under the definitions
  515. X   and restrictions of United States law.
  516. X
  517. X   History of Revisions:
  518. X        None yet.
  519. X*)
  520. X
  521. XFROM SYSTEM    IMPORT ADDRESS, TSIZE;
  522. XFROM WordAlign IMPORT WordAlign;
  523. XFROM Storage   IMPORT ALLOCATE, DEALLOCATE;
  524. X
  525. XIMPORT DynItem;
  526. X
  527. XTYPE
  528. X  Object     = POINTER TO ListRecord;
  529. X  ListRecord = RECORD
  530. X                 PrevList, NextList:          Object;
  531. X                 NextFreeByte:                ADDRESS;
  532. X                 AmountLeft, ItemCount, Size: LONGCARD;
  533. X                 FirstItem, LastItem,
  534. X                 LowGapItem, CurrentGapItem:  DynItem.Object;
  535. X               END;
  536. X
  537. XVAR
  538. X  FirstList:      Object;
  539. X  ListRecordSize: LONGCARD;
  540. X  NilDynItem:     DynItem.Object;
  541. X
  542. XCONST
  543. X  BlockSizeResolution = 1024;
  544. X
  545. X
  546. XPROCEDURE GetListWithSpace(Size: LONGCARD): Object;
  547. XVAR
  548. X  NewList: Object;
  549. XBEGIN
  550. X  IF FirstList = NIL THEN
  551. X    FirstList := New(Size);
  552. X    RETURN FirstList;
  553. X  END;
  554. X
  555. X  NewList := FindListWithSpace(FirstList, Size);
  556. X  IF NewList <> NIL THEN
  557. X    RETURN NewList;
  558. X  END;
  559. X
  560. X  NewList := New(Size);
  561. X  IF NewList = NIL THEN
  562. X    RETURN NIL;
  563. X  END;
  564. X
  565. X  LinkInList(NewList, FirstList);
  566. X  RETURN NewList;
  567. XEND GetListWithSpace;
  568. X
  569. X
  570. XPROCEDURE New(Size: LONGCARD): Object;
  571. XVAR
  572. X  NewObject: Object;
  573. XBEGIN
  574. X  Size := Size + ListRecordSize;
  575. X  Size := ((Size - 1) DIV BlockSizeResolution + 1) * BlockSizeResolution;
  576. X  ALLOCATE(NewObject, Size);
  577. X  IF NewObject = NIL THEN
  578. X    RETURN NIL;
  579. X  END;
  580. X  NewObject^.PrevList     := NIL;
  581. X  NewObject^.NextList     := NIL;
  582. X  NewObject^.AmountLeft   := Size - ListRecordSize;
  583. X  NewObject^.Size         := Size;
  584. X  NewObject^.NextFreeByte := ADDRESS(LONGCARD(NewObject) + ListRecordSize);
  585. X  NewObject^.FirstItem      := NilDynItem;
  586. X  NewObject^.LastItem       := NilDynItem;
  587. X  NewObject^.LowGapItem     := NilDynItem;
  588. X  NewObject^.CurrentGapItem := NilDynItem;
  589. X  RETURN NewObject;
  590. XEND New;
  591. X
  592. X
  593. XPROCEDURE FindListWithSpace(List: Object; Size: LONGCARD): Object;
  594. XBEGIN
  595. X  LOOP
  596. X    IF List = NIL THEN
  597. X      RETURN NIL;
  598. X    END;
  599. X
  600. X    IF List^.AmountLeft >= Size THEN
  601. X      RETURN List;
  602. X    END;
  603. X
  604. X    List := List^.NextList;
  605. X  END;
  606. XEND FindListWithSpace;
  607. X
  608. X
  609. XPROCEDURE LinkInList(NewList: Object; OldList: Object);
  610. XBEGIN
  611. X  IF OldList <> NIL THEN
  612. X    NewList^.PrevList := OldList;
  613. X    NewList^.NextList := OldList^.NextList;
  614. X    NewList^.PrevList^.NextList := NewList;
  615. X    IF NewList^.NextList <> NIL THEN
  616. X      NewList^.NextList^.PrevList := NewList;
  617. X    END;
  618. X  ELSE
  619. X    NewList^.PrevList := NIL;
  620. X    NewList^.NextList := NIL;
  621. X  END;
  622. XEND LinkInList;
  623. X
  624. X
  625. XPROCEDURE UnlinkList(List: Object);
  626. XBEGIN
  627. X  IF List^.PrevList <> NIL THEN
  628. X    List^.PrevList^.NextList := List^.NextList;
  629. X  END;
  630. X
  631. X  IF List^.NextList <> NIL THEN
  632. X    List^.NextList^.PrevList := List^.PrevList;
  633. X  END;
  634. X
  635. X  IF List = FirstList THEN
  636. X    FirstList := List^.NextList;
  637. X  END;
  638. XEND UnlinkList;
  639. X
  640. X
  641. XPROCEDURE GetChunk(List: Object; Size: LONGCARD): ADDRESS;
  642. XVAR
  643. X  Chunk: ADDRESS;
  644. XBEGIN
  645. X  Chunk := List^.NextFreeByte;
  646. X  List^.NextFreeByte := ADDRESS(LONGCARD(List^.NextFreeByte) + Size);
  647. X  List^.AmountLeft   := List^.AmountLeft - Size;
  648. X  RETURN Chunk;
  649. XEND GetChunk;
  650. X
  651. X
  652. XPROCEDURE LinkItem(List: Object; Item: ADDRESS);
  653. XBEGIN
  654. X(* Link it to first item in list *)
  655. X  DynItem.LinkAfter(DynItem.Object(Item), List^.LastItem);
  656. X
  657. X  List^.LastItem := DynItem.Object(Item);
  658. X  IF ADDRESS(List^.FirstItem) = ADDRESS(NilDynItem) THEN
  659. X    List^.FirstItem := DynItem.Object(Item);
  660. X  END;
  661. X  List^.ItemCount := List^.ItemCount + 1;
  662. XEND LinkItem;
  663. X
  664. X
  665. XPROCEDURE Percolate(List: Object);
  666. XVAR
  667. X  MovedItem, OldItem: DynItem.Object;
  668. X  NextAddr: ADDRESS;
  669. X  ReclaimableSpace: LONGCARD;
  670. XBEGIN
  671. X(* If ItemCount is zero, then list is no longer needed;  reclaim it and
  672. X   exit
  673. X*)
  674. X  IF List^.ItemCount = 0 THEN
  675. X    UnlinkList(List);
  676. X    DEALLOCATE(List, List^.Size);
  677. X    RETURN;
  678. X  END;
  679. X
  680. X(* Move an item *)
  681. X  OldItem   := List^.CurrentGapItem;
  682. X  IF ADDRESS(OldItem) <> ADDRESS(NilDynItem) THEN
  683. X    MovedItem := DynItem.MoveDown(OldItem);
  684. X
  685. X(* Update list variables *)
  686. X    IF ADDRESS(List^.FirstItem) = ADDRESS(OldItem) THEN
  687. X      List^.FirstItem := MovedItem;
  688. X    END;
  689. X
  690. X    IF ADDRESS(List^.LastItem) = ADDRESS(OldItem) THEN
  691. X      List^.LastItem := MovedItem;
  692. X    END;
  693. X
  694. X    IF ADDRESS(List^.LowGapItem) = ADDRESS(OldItem) THEN
  695. X      List^.LowGapItem := DynItem.GetNext(MovedItem);
  696. X    END;
  697. X
  698. X    List^.CurrentGapItem := DynItem.GetNext(MovedItem);
  699. X    IF ADDRESS(List^.CurrentGapItem) = ADDRESS(NilDynItem) THEN
  700. X      List^.CurrentGapItem := List^.LowGapItem;
  701. X    END;
  702. X
  703. X(* Reclaim space between last item and first free byte *)
  704. X    NextAddr := DynItem.NextAddr(List^.LastItem);
  705. X    ReclaimableSpace := LONGCARD(List^.NextFreeByte - NextAddr);
  706. X    List^.AmountLeft := List^.AmountLeft + ReclaimableSpace;
  707. X    List^.NextFreeByte := NextAddr;
  708. X  END;
  709. XEND Percolate;
  710. X
  711. X
  712. XPROCEDURE UnlinkItem(List: Object; Item: ADDRESS);
  713. XBEGIN
  714. X  IF Item = ADDRESS(List^.LastItem) THEN
  715. X    List^.LastItem := DynItem.GetPrev(DynItem.Object(Item));
  716. X  END;
  717. X
  718. X  IF Item = ADDRESS(List^.FirstItem) THEN
  719. X    List^.FirstItem := DynItem.GetNext(DynItem.Object(Item));
  720. X  END;
  721. X
  722. X  IF (Item <= ADDRESS(List^.LowGapItem)) OR
  723. X     (NIL  =  ADDRESS(List^.LowGapItem)) THEN
  724. X    List^.LowGapItem := DynItem.GetNext(DynItem.Object(Item));
  725. X  END;
  726. X
  727. X  IF Item = ADDRESS(List^.CurrentGapItem) THEN
  728. X    List^.CurrentGapItem := DynItem.GetNext(DynItem.Object(Item));
  729. X  END;
  730. X
  731. X  IF NIL = ADDRESS(List^.CurrentGapItem) THEN
  732. X    List^.CurrentGapItem := List^.LowGapItem;
  733. X  END;
  734. X
  735. X  List^.ItemCount := List^.ItemCount - 1;
  736. X
  737. X  DynItem.Unlink(DynItem.Object(Item));
  738. XEND UnlinkItem;
  739. X
  740. X
  741. XPROCEDURE NextAddr(List: Object): ADDRESS;
  742. XBEGIN
  743. X  RETURN ADDRESS(LONGCARD(List) + ListRecordSize);
  744. XEND NextAddr;
  745. X
  746. X
  747. XPROCEDURE DisposeAll();
  748. XVAR
  749. X  CurrentList, Temp: Object;
  750. XBEGIN
  751. X  CurrentList := FirstList;
  752. X  LOOP
  753. X    IF CurrentList = NIL THEN
  754. X      EXIT;
  755. X    END;
  756. X    Temp := CurrentList^.NextList;
  757. X    DEALLOCATE(CurrentList, CurrentList^.Size);
  758. X    CurrentList := Temp;
  759. X  END;
  760. X  FirstList := NIL;
  761. XEND DisposeAll;
  762. X
  763. X
  764. XPROCEDURE Nil(List: Object): BOOLEAN;
  765. XBEGIN
  766. X  RETURN (List = NIL);
  767. XEND Nil;
  768. X
  769. X
  770. XBEGIN
  771. X  FirstList := NIL;
  772. X  ListRecordSize := WordAlign(TSIZE(ListRecord));
  773. X  NilDynItem := DynItem.NilObject();
  774. XEND DynItemList.
  775. END_OF_FILE
  776. if test 6556 -ne `wc -c <'DynItemList.mod'`; then
  777.     echo shar: \"'DynItemList.mod'\" unpacked with wrong size!
  778. fi
  779. # end of 'DynItemList.mod'
  780. fi
  781. if test -f 'DynTest.mod' -a "${1}" != "-c" ; then 
  782.   echo shar: Will not clobber existing file \"'DynTest.mod'\"
  783. else
  784. echo shar: Extracting \"'DynTest.mod'\" \(6342 characters\)
  785. sed "s/^X//" >'DynTest.mod' <<'END_OF_FILE'
  786. XMODULE DynTest;
  787. X
  788. X(* Product: Incremental Storage Manager
  789. X
  790. X   Version: 1.0
  791. X
  792. X   Author:
  793. X        Daniel B. Hankins
  794. X        143 Montgomery Street
  795. X        Poughkeepsie, NY 12601
  796. X        dan-hankins@cup.portal.com
  797. X
  798. X   Creation Date: 1989
  799. X
  800. X   Release  Date: November 21, 1989
  801. X
  802. X   Notice of Intellectual Property:
  803. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  804. X   this program and all its parts in the public domain, under the definitions
  805. X   and restrictions of United States law.
  806. X
  807. X   History of Revisions:
  808. X        None yet.
  809. X*)
  810. X
  811. XFROM SYSTEM        IMPORT ADDRESS;
  812. XFROM DOSProcessHandler IMPORT Exit;
  813. XFROM RandomNumbers IMPORT Seed, Random;
  814. XFROM InOut         IMPORT WriteString, WriteCard, WriteLn;
  815. XFROM LongInOut     IMPORT WriteLongCard;
  816. X
  817. XIMPORT DynamicItem;
  818. XIMPORT Strings;
  819. X
  820. X(*
  821. XFROM Debug         IMPORT DebugFlag;
  822. X*)
  823. X
  824. X
  825. XTYPE
  826. X  Transparent = POINTER TO LONGCARD;
  827. X  StrPtr = POINTER TO Strings.String;
  828. X
  829. XCONST
  830. X  ArraySize = 50;
  831. X
  832. XVAR
  833. X  ArrayIndex: CARDINAL;
  834. X  TempIndex, Index: LONGCARD;
  835. X  TestArray: ARRAY [1..ArraySize] OF RECORD
  836. X                                       count: CARDINAL;
  837. X                                       size:  LONGCARD;
  838. X                                       ref:   DynamicItem.Object;
  839. X                                     END;
  840. X  ItemVar: Transparent;
  841. X  Prose, Temp1, Temp2: Strings.String;
  842. X  Comp: Strings.CompareResults;
  843. X  NewString: StrPtr;
  844. X
  845. X
  846. XPROCEDURE DoesNothing(NotUsed: ADDRESS);
  847. XBEGIN
  848. XEND DoesNothing;
  849. X
  850. X
  851. XBEGIN
  852. X  TempIndex := 1;
  853. X  Seed(314);
  854. X  Prose := 'Four-score-and-seven-years-ago,-our-forefathers...Dont-sell';
  855. X  Strings.Concat(Prose, 
  856. X           '-Shell-Sort-short.-Did-I-say-something-wrong?--Pardon-me-for',
  857. X           Prose);
  858. X  Strings.Concat(Prose,
  859. X           '-breathing-which-I-never-do-anyway-so-I-dont-know-why-I-bother',
  860. X           Prose);
  861. X  Strings.Concat(Prose,
  862. X           '-to-say-it-oh-god-im-so-depressed.--Life?-Dont-talk-to-me-about',
  863. X           Prose);
  864. X
  865. X  FOR ArrayIndex := 1 TO ArraySize DO
  866. X    TestArray[ArrayIndex].ref      := DynamicItem.NilObject();
  867. X    TestArray[ArrayIndex].count    := 0;
  868. X    TestArray[ArrayIndex].size     := LONG(0);
  869. X  END;
  870. X  WriteString("Finished initialization.");
  871. X  WriteLn;
  872. X  FOR Index := 1 TO 2500 DO
  873. X    IF FALSE = TRUE THEN
  874. X      (* DebugFlag := TRUE; *)
  875. X    END;
  876. X    ArrayIndex := Random(ArraySize) + 1;
  877. X    WriteLn;
  878. X    IF Random(TestArray[ArrayIndex].count+2) = 0 THEN
  879. X      IF TestArray[ArrayIndex].count > 0 THEN
  880. X        WriteLongCard(Index + 25 * (TempIndex - 1), 5); WriteString(': ');
  881. X        WriteString("Adding ref to item");
  882. X        WriteCard(ArrayIndex,10); WriteString("."); WriteLn;
  883. X
  884. X        ItemVar := Transparent(TestArray[ArrayIndex].ref);
  885. X        TestArray[ArrayIndex].ref :=
  886. X          DynamicItem.Ref(TestArray[ArrayIndex].ref);
  887. X        TestArray[ArrayIndex].count := TestArray[ArrayIndex].count + 1;
  888. X
  889. X        NewString := DynamicItem.Access(TestArray[ArrayIndex].ref);
  890. X        Strings.Assign(Temp1, NewString^);
  891. X        Strings.Assign(Temp2,'');
  892. X        Strings.Copy(Prose, 0,
  893. X                     SHORT(TestArray[ArrayIndex].size)-1, Temp2);
  894. X        Comp := Strings.Compare(Temp1, Temp2);
  895. X        IF NOT(Comp = Strings.Equal) THEN
  896. X          WriteString("Error in comparison."); WriteLn();
  897. X          Exit(0);
  898. X        END;
  899. X
  900. X        WriteString("Ref, Item, Count, Size =");
  901. X        WriteLongCard(LONGCARD(TestArray[ArrayIndex].ref),10);
  902. X        ItemVar := Transparent(TestArray[ArrayIndex].ref);
  903. X        WriteLongCard(ItemVar^,11);
  904. X        WriteCard(TestArray[ArrayIndex].count,10);
  905. X        WriteLongCard(TestArray[ArrayIndex].size,10);
  906. X        WriteLn;
  907. X      ELSE
  908. X        WriteLongCard(Index + 25 * (TempIndex - 1), 5); WriteString(': ');
  909. X        WriteString("Getting new item");
  910. X        WriteCard(ArrayIndex,10); WriteString("."); WriteLn;
  911. X
  912. X        TestArray[ArrayIndex].size := LONG(Random(200) + 1);
  913. X
  914. X        WriteString("Size is"); WriteLongCard(TestArray[ArrayIndex].size, 10);
  915. X        WriteLn;
  916. X
  917. X        ItemVar := Transparent(TestArray[ArrayIndex].ref);
  918. X        TestArray[ArrayIndex].ref :=
  919. X          DynamicItem.New(TestArray[ArrayIndex].size, DoesNothing, DoesNothing);
  920. X
  921. X        IF NOT(DynamicItem.Nil(TestArray[ArrayIndex].ref)) THEN
  922. X          NewString := StrPtr(DynamicItem.Access(TestArray[ArrayIndex].ref));
  923. X          Strings.Copy(Prose, 0,
  924. X                       SHORT(TestArray[ArrayIndex].size)-1, NewString^);
  925. X
  926. X          WriteString("Got new item."); WriteLn;
  927. X
  928. X          TestArray[ArrayIndex].count := TestArray[ArrayIndex].count + 1;
  929. X
  930. X          WriteString("Ref, Item, Count, Size =");
  931. X          WriteLongCard(LONGCARD(TestArray[ArrayIndex].ref),10);
  932. X          ItemVar := Transparent(TestArray[ArrayIndex].ref);
  933. X          WriteLongCard(ItemVar^,11);
  934. X          WriteCard(TestArray[ArrayIndex].count,10);
  935. X          WriteLongCard(TestArray[ArrayIndex].size,10);
  936. X          WriteLn;
  937. X        ELSE
  938. X          WriteString("No more space!");
  939. X          WriteLn;
  940. X          Exit(0);
  941. X        END;
  942. X      END;
  943. X    ELSE
  944. X      IF TestArray[ArrayIndex].count > 0 THEN
  945. X        WriteLongCard(Index + 25 * (TempIndex - 1), 5); WriteString(': ');
  946. X        WriteString("Getting rid of item");
  947. X        WriteCard(ArrayIndex,10); WriteString("."); WriteLn;
  948. X
  949. X        NewString := DynamicItem.Access(TestArray[ArrayIndex].ref);
  950. X        Strings.Assign(Temp1, NewString^);
  951. X        Strings.Assign(Temp2,'');
  952. X        Strings.Copy(Prose, 0,
  953. X                     SHORT(TestArray[ArrayIndex].size)-1, Temp2);
  954. X        Comp := Strings.Compare(Temp1, Temp2);
  955. X        IF NOT(Comp = Strings.Equal) THEN
  956. X          WriteString("Error in comparison."); WriteLn();
  957. X          Exit(0);
  958. X        END;
  959. X
  960. X        ItemVar := Transparent(TestArray[ArrayIndex].ref);
  961. X        DynamicItem.Dispose(TestArray[ArrayIndex].ref);
  962. X        TestArray[ArrayIndex].count := TestArray[ArrayIndex].count - 1;
  963. X
  964. X        WriteString("Ref, Item, Count, Size =");
  965. X        WriteLongCard(LONGCARD(TestArray[ArrayIndex].ref),10);
  966. X        ItemVar := Transparent(TestArray[ArrayIndex].ref);
  967. X        WriteLongCard(ItemVar^,11);
  968. X        WriteCard(TestArray[ArrayIndex].count,10);
  969. X        WriteLongCard(TestArray[ArrayIndex].size,10);
  970. X        WriteLn;
  971. X      ELSE
  972. X        WriteString("No item yet at index");
  973. X        WriteCard(ArrayIndex,10); WriteString("."); WriteLn;
  974. X      END;
  975. X    END;
  976. X  END;
  977. X  DynamicItem.DisposeAll();
  978. X  WriteString("Finished test.");
  979. X  WriteLn;
  980. XEND DynTest.
  981. END_OF_FILE
  982. if test 6342 -ne `wc -c <'DynTest.mod'`; then
  983.     echo shar: \"'DynTest.mod'\" unpacked with wrong size!
  984. fi
  985. # end of 'DynTest.mod'
  986. fi
  987. if test -f 'DynamicItem.def' -a "${1}" != "-c" ; then 
  988.   echo shar: Will not clobber existing file \"'DynamicItem.def'\"
  989. else
  990. echo shar: Extracting \"'DynamicItem.def'\" \(5796 characters\)
  991. sed "s/^X//" >'DynamicItem.def' <<'END_OF_FILE'
  992. XDEFINITION MODULE DynamicItem;
  993. X
  994. X(* Product: Incremental Storage Manager
  995. X
  996. X   Version: 1.0
  997. X
  998. X   Author:
  999. X        Daniel B. Hankins
  1000. X        143 Montgomery Street
  1001. X        Poughkeepsie, NY 12601
  1002. X        dan-hankins@cup.portal.com
  1003. X
  1004. X   Creation Date: 1989
  1005. X
  1006. X   Release  Date: November 21, 1989
  1007. X
  1008. X   Notice of Intellectual Property:
  1009. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  1010. X   this program and all its parts in the public domain, under the definitions
  1011. X   and restrictions of United States law.
  1012. X
  1013. X   History of Revisions:
  1014. X        None yet.
  1015. X*)
  1016. X
  1017. XFROM SYSTEM IMPORT ADDRESS;
  1018. X
  1019. XTYPE
  1020. X  Object;
  1021. X
  1022. X  InitProc = PROCEDURE(ADDRESS);
  1023. X  TermProc = InitProc;
  1024. X
  1025. XPROCEDURE New(Size: LONGCARD; InitIt: InitProc; TermIt: TermProc): Object;
  1026. X(* Size:   *in*  Size in bytes of chunk to be allocated
  1027. X   InitIt: *in*  The procedure which will initialize the contents of the
  1028. X                 chunk.  It is passed the address of the first byte of the
  1029. X                 chunk.
  1030. X   TermIt: *in*  The procedure which will clean up the contents of the
  1031. X                 chunk when its storage is reclaimed.  For instance, if
  1032. X                 the chunk contains variables of type DynamicItem.Object,
  1033. X                 TermIt should DynamicItem.Dispose each of them so that
  1034. X                 their reference counts can be accurately maintained.
  1035. X           *out* The resulting object
  1036. X*)
  1037. X
  1038. XPROCEDURE Ref(Item: Object): Object;
  1039. X(* Item: *in*  The chunk to which another reference is to be generated.
  1040. X         *out* The chunk after its reference count is incremented.
  1041. X
  1042. X   Explanations and Recommendations:
  1043. X        Although the Modula-2 compiler will allow the programmer to perform
  1044. X   assignment between variables of type DynamicItem.Object, she should not.
  1045. X   This storage manager relies on a technique called reference counts.  The
  1046. X   reference count (which is embedded in the header of a storage chunk) is
  1047. X   intended to reflect the number of variables (pointers, actually) which
  1048. X   are accessing the same chunk.  The reason for this is so that the
  1049. X   storage manager will know when it can remove the chunk from the active
  1050. X   list and reclaim the storage it consumed.
  1051. X        So if variables A, B, and C are all of type DynamicItem.Object, and
  1052. X   all reference the same storage chunk, then the reference count of the
  1053. X   chunk should be three.
  1054. X        To make two variables refer to the same object, use the following:
  1055. X
  1056. X        A := DynamicItem.Ref(B);
  1057. X
  1058. X   instead of
  1059. X
  1060. X        A := B;
  1061. X
  1062. X        If you want to copy the contents of an chunk A into another chunk
  1063. X   B, then the programmer should create a new dynamic item object B, access
  1064. X   the contents of both, and then copy the contents.  For instance:
  1065. X
  1066. X        B := DynamicItem.New(ASize, AInit, ATerm);
  1067. X        ACopy(DynamicItem.Access(A), DynamicItem.Access(B));
  1068. X
  1069. X   where ACopy takes a pair of pointers to the kind of chunk being copied.
  1070. X*)
  1071. X
  1072. X
  1073. XPROCEDURE Dispose(Item: Object);
  1074. X(* Item: *in* The chunk to be disposed of.
  1075. X
  1076. X   Explanations and Recommendations:
  1077. X        Dispose does *not* necessarily reclaim the storage used by a chunk.
  1078. X   Dispose decrements the reference count of the chunk (see procedure Ref,
  1079. X   above); there is now one less pointer to the chunk.  Only when there are
  1080. X   no pointers left to a chunk (i.e. reference count = 0) does Dispose
  1081. X   actually attempt to reclaim the storage used by the chunk.  Just
  1082. X   before reclaiming that storage, it runs the TermIt procedure (see
  1083. X   procedure New, above) stored in the header of the chunk against the
  1084. X   contents of that chunk.  The TermIt procedure is meant to be used for
  1085. X   Dispose-ing of any chunks the chunk may reference.
  1086. X        For instance, suppose that the chunk the programmer is working
  1087. X   with is a record which has three variables of type DynamicItem.Object.
  1088. X   TermIt should DynamicItem.Dispose each of the three variables.
  1089. X   Otherwise, the three chunks referenced will *never* be reclaimed;
  1090. X   their reference counts will never go to zero, and they will become
  1091. X   unusable dead storage.
  1092. X*)
  1093. X
  1094. XPROCEDURE Access(Item: Object): ADDRESS;
  1095. X(* Item: *in*   The chunk which is to be accessed.
  1096. X         *out*  The address of the contents of the chunk.
  1097. X
  1098. X   Explanations and Recommendations:
  1099. X        Whenever DynamicItem.New or DynamicItem.Dispose is called,
  1100. X   the contents of a chunk may move in memory.  So it is a good idea to
  1101. X   avoid code like this:
  1102. X
  1103. X        ChunkPtr := DynamicItem.Access(ChunkVar);
  1104. X        ...
  1105. X        (* other code *)
  1106. X        ...
  1107. X        DynamicItem.Dispose(ChunkVar2);
  1108. X        ChunkPtr^.XValue := 10;
  1109. X
  1110. X   because ChunkPtr may no longer be pointing at the contents of the
  1111. X   chunk after a New or Dispose is done.  A better practice is to
  1112. X   *always* Access a chunk *just before* its contents are to be
  1113. X   manipulated, like this:
  1114. X
  1115. X        ChunkPtr := DynamicItem.Access(ChunkVar);
  1116. X        ...
  1117. X        (* other code *)
  1118. X        ...
  1119. X        DynamicItem.Dispose(ChunkVar2);
  1120. X>>>     ChunkPtr := DynamicItem.Access(ChunkVar);
  1121. X        ChunkPtr^.XValue := 10;
  1122. X*)
  1123. X
  1124. XPROCEDURE Set(Item:Object; NewDynItem: ADDRESS);
  1125. X(* DO NOT USE THIS PROCEDURE; IT IS FOR THE EXCLUSIVE USE OF OTHER PARTS
  1126. X   OF THE STORAGE MANAGER!
  1127. X*)
  1128. X
  1129. XPROCEDURE DisposeAll();
  1130. X(* This procedure returns *all* storage allocated by the storage manager
  1131. X   to the operating system.  It is a good idea to call this procedure
  1132. X   just before exiting your program;  it makes sure you haven't forgotten
  1133. X   to return any resources you've used.
  1134. X*)
  1135. X
  1136. XPROCEDURE NilObject(): Object;
  1137. X(* This procedure returns an uninitialized chunk, which cannot be used
  1138. X   except for testing to see if another chunk is uninitialized.  It is
  1139. X   primarily for use of other storage manager procedures.
  1140. X*)
  1141. X
  1142. XPROCEDURE Nil(Item: Object): BOOLEAN;
  1143. X(* This procedure returns TRUE if a chunk is uninitialized, FALSE 
  1144. X   otherwise.
  1145. X*)
  1146. X
  1147. XEND DynamicItem.
  1148. END_OF_FILE
  1149. if test 5796 -ne `wc -c <'DynamicItem.def'`; then
  1150.     echo shar: \"'DynamicItem.def'\" unpacked with wrong size!
  1151. fi
  1152. # end of 'DynamicItem.def'
  1153. fi
  1154. if test -f 'DynamicItem.mod' -a "${1}" != "-c" ; then 
  1155.   echo shar: Will not clobber existing file \"'DynamicItem.mod'\"
  1156. else
  1157. echo shar: Extracting \"'DynamicItem.mod'\" \(2748 characters\)
  1158. sed "s/^X//" >'DynamicItem.mod' <<'END_OF_FILE'
  1159. XIMPLEMENTATION MODULE DynamicItem;
  1160. X
  1161. X(* Product: Incremental Storage Manager
  1162. X
  1163. X   Version: 1.0
  1164. X
  1165. X   Author:
  1166. X        Daniel B. Hankins
  1167. X        143 Montgomery Street
  1168. X        Poughkeepsie, NY 12601
  1169. X        dan-hankins@cup.portal.com
  1170. X
  1171. X   Creation Date: 1989
  1172. X
  1173. X   Release  Date: November 21, 1989
  1174. X
  1175. X   Notice of Intellectual Property:
  1176. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  1177. X   this program and all its parts in the public domain, under the definitions
  1178. X   and restrictions of United States law.
  1179. X
  1180. X   History of Revisions:
  1181. X        None yet.
  1182. X*)
  1183. X
  1184. XFROM SYSTEM      IMPORT ADDRESS, TSIZE;
  1185. X
  1186. XIMPORT HandleCollection;
  1187. XIMPORT DynItem;
  1188. XIMPORT DynItemList;
  1189. X
  1190. XTYPE
  1191. X  Object = POINTER TO Handle;
  1192. X  Handle = DynItem.Object;
  1193. X
  1194. X
  1195. XPROCEDURE New(Size: LONGCARD; InitIt: InitProc; TermIt: TermProc): Object;
  1196. XVAR
  1197. X  DItem:      Object;
  1198. X  ItemHandle: Handle;
  1199. XBEGIN
  1200. X(* New(Size, InitIt, Item) <-
  1201. X     DynItem.New(Size, ItemHandle),
  1202. X     New2(ItemHandle, InitIt, Item).
  1203. X   New2(ItemHandle, InitIt, Item) <-
  1204. X     DynItem.Nil(ItemHandle),
  1205. X     SetValue(Item,NIL).
  1206. X   New2(ItemHandle, InitIt, Item) <-
  1207. X     HandleCollection.NewHandle(DItem),
  1208. X     New3(ItemHandle, DItem, InitIt, Item).
  1209. X   New3(ItemHandle, DItem, InitIt, Item) <-
  1210. X     EqualValue(DItem, NIL),
  1211. X     DynItem.Kill(ItemHandle),
  1212. X     SetValue(Item, NIL).
  1213. X   New3(ItemHandle, DItem, InitIt, Item) <-
  1214. X     SetValue(DItem^, ItemHandle),
  1215. X     DynItem.SetHandle(DItem^, DItem),
  1216. X     DynItem.Percolate(DItem^),
  1217. X     DynItem.Percolate(DItem^),
  1218. X     DynItem.Init(DItem^, InitIt),
  1219. X     SetValue(Item, DItem).
  1220. X*)
  1221. X  ItemHandle := DynItem.New(Size, TermIt);
  1222. X  IF DynItem.Nil(ItemHandle) THEN
  1223. X    RETURN NIL;
  1224. X  END;
  1225. X
  1226. X  DItem := HandleCollection.NewHandle();
  1227. X  IF DItem = NIL THEN
  1228. X    DynItem.Kill(ItemHandle);
  1229. X    RETURN NIL;
  1230. X  END;
  1231. X
  1232. X  DItem^ := ItemHandle;
  1233. X  DynItem.SetHandle(DItem^, DItem);
  1234. X  DynItem.Percolate(DItem^);
  1235. X  DynItem.Percolate(DItem^);
  1236. X  DynItem.Init(DItem^, InitIt);
  1237. X
  1238. X  RETURN DItem;
  1239. XEND New;
  1240. X
  1241. X
  1242. XPROCEDURE Ref(Item: Object): Object;
  1243. XBEGIN
  1244. X  DynItem.Ref(Item^);
  1245. X  RETURN Item;
  1246. XEND Ref;
  1247. X
  1248. X
  1249. XPROCEDURE Dispose(Item: Object);
  1250. XVAR
  1251. X  List: DynItemList.Object;
  1252. XBEGIN
  1253. X  List := DynItem.GetList(Item^);
  1254. X  IF DynItem.Dispose(Item^) THEN
  1255. X    HandleCollection.DisposeHandle(Item);
  1256. X  END;
  1257. X  DynItemList.Percolate(List);
  1258. XEND Dispose;
  1259. X
  1260. X
  1261. XPROCEDURE Access(Item: Object): ADDRESS;
  1262. XBEGIN
  1263. X  RETURN DynItem.Access(Item^);
  1264. XEND Access;
  1265. X
  1266. X
  1267. XPROCEDURE Set(Item:Object; NewDynItem: ADDRESS);
  1268. XBEGIN
  1269. X  Item^ := DynItem.Object(NewDynItem);
  1270. XEND Set;
  1271. X
  1272. X
  1273. XPROCEDURE DisposeAll();
  1274. XBEGIN
  1275. X  DynItemList.DisposeAll();
  1276. X  HandleCollection.DisposeAll();
  1277. XEND DisposeAll;
  1278. X
  1279. X
  1280. XPROCEDURE NilObject(): Object;
  1281. XBEGIN
  1282. X  RETURN NIL;
  1283. XEND NilObject;
  1284. X
  1285. X
  1286. XPROCEDURE Nil(Item: Object): BOOLEAN;
  1287. XBEGIN
  1288. X  RETURN (Item = NIL);
  1289. XEND Nil;
  1290. X
  1291. XEND DynamicItem.
  1292. END_OF_FILE
  1293. if test 2748 -ne `wc -c <'DynamicItem.mod'`; then
  1294.     echo shar: \"'DynamicItem.mod'\" unpacked with wrong size!
  1295. fi
  1296. # end of 'DynamicItem.mod'
  1297. fi
  1298. if test -f 'FreeHandle.def' -a "${1}" != "-c" ; then 
  1299.   echo shar: Will not clobber existing file \"'FreeHandle.def'\"
  1300. else
  1301. echo shar: Extracting \"'FreeHandle.def'\" \(714 characters\)
  1302. sed "s/^X//" >'FreeHandle.def' <<'END_OF_FILE'
  1303. XDEFINITION MODULE FreeHandle;
  1304. X
  1305. X(* Product: Incremental Storage Manager
  1306. X
  1307. X   Version: 1.0
  1308. X
  1309. X   Author:
  1310. X        Daniel B. Hankins
  1311. X        143 Montgomery Street
  1312. X        Poughkeepsie, NY 12601
  1313. X        dan-hankins@cup.portal.com
  1314. X
  1315. X   Creation Date: 1989
  1316. X
  1317. X   Release  Date: November 21, 1989
  1318. X
  1319. X   Notice of Intellectual Property:
  1320. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  1321. X   this program and all its parts in the public domain, under the definitions
  1322. X   and restrictions of United States law.
  1323. X
  1324. X   History of Revisions:
  1325. X        None yet.
  1326. X*)
  1327. X
  1328. XTYPE
  1329. X  Object;
  1330. X
  1331. XPROCEDURE Next(FHObject: Object): Object;
  1332. X
  1333. XPROCEDURE NilObject(): Object;
  1334. X
  1335. XPROCEDURE Nil(FHObject: Object): BOOLEAN;
  1336. X
  1337. XEND FreeHandle.
  1338. END_OF_FILE
  1339. if test 714 -ne `wc -c <'FreeHandle.def'`; then
  1340.     echo shar: \"'FreeHandle.def'\" unpacked with wrong size!
  1341. fi
  1342. # end of 'FreeHandle.def'
  1343. fi
  1344. if test -f 'FreeHandle.mod' -a "${1}" != "-c" ; then 
  1345.   echo shar: Will not clobber existing file \"'FreeHandle.mod'\"
  1346. else
  1347. echo shar: Extracting \"'FreeHandle.mod'\" \(904 characters\)
  1348. sed "s/^X//" >'FreeHandle.mod' <<'END_OF_FILE'
  1349. XIMPLEMENTATION MODULE FreeHandle;
  1350. X
  1351. X(* Product: Incremental Storage Manager
  1352. X
  1353. X   Version: 1.0
  1354. X
  1355. X   Author:
  1356. X        Daniel B. Hankins
  1357. X        143 Montgomery Street
  1358. X        Poughkeepsie, NY 12601
  1359. X        dan-hankins@cup.portal.com
  1360. X
  1361. X   Creation Date: 1989
  1362. X
  1363. X   Release  Date: November 21, 1989
  1364. X
  1365. X   Notice of Intellectual Property:
  1366. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  1367. X   this program and all its parts in the public domain, under the definitions
  1368. X   and restrictions of United States law.
  1369. X
  1370. X   History of Revisions:
  1371. X        None yet.
  1372. X*)
  1373. X
  1374. XTYPE
  1375. X  Object           = POINTER TO FreeHandleObject;
  1376. X  FreeHandleObject = Object;
  1377. X
  1378. X
  1379. XPROCEDURE Next(FHObject: Object): Object;
  1380. XBEGIN
  1381. X  RETURN FHObject^;
  1382. XEND Next;
  1383. X
  1384. X
  1385. XPROCEDURE NilObject(): Object;
  1386. XBEGIN
  1387. X  RETURN NIL;
  1388. XEND NilObject;
  1389. X
  1390. X
  1391. XPROCEDURE Nil(FHObject: Object): BOOLEAN;
  1392. XBEGIN
  1393. X  RETURN (FHObject = NIL);
  1394. XEND Nil;
  1395. X
  1396. X
  1397. XEND FreeHandle.
  1398. END_OF_FILE
  1399. if test 904 -ne `wc -c <'FreeHandle.mod'`; then
  1400.     echo shar: \"'FreeHandle.mod'\" unpacked with wrong size!
  1401. fi
  1402. # end of 'FreeHandle.mod'
  1403. fi
  1404. if test -f 'HandleCollection.def' -a "${1}" != "-c" ; then 
  1405.   echo shar: Will not clobber existing file \"'HandleCollection.def'\"
  1406. else
  1407. echo shar: Extracting \"'HandleCollection.def'\" \(721 characters\)
  1408. sed "s/^X//" >'HandleCollection.def' <<'END_OF_FILE'
  1409. XDEFINITION MODULE HandleCollection;
  1410. X
  1411. X(* Product: Incremental Storage Manager
  1412. X
  1413. X   Version: 1.0
  1414. X
  1415. X   Author:
  1416. X        Daniel B. Hankins
  1417. X        143 Montgomery Street
  1418. X        Poughkeepsie, NY 12601
  1419. X        dan-hankins@cup.portal.com
  1420. X
  1421. X   Creation Date: 1989
  1422. X
  1423. X   Release  Date: November 21, 1989
  1424. X
  1425. X   Notice of Intellectual Property:
  1426. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  1427. X   this program and all its parts in the public domain, under the definitions
  1428. X   and restrictions of United States law.
  1429. X
  1430. X   History of Revisions:
  1431. X        None yet.
  1432. X*)
  1433. X
  1434. XFROM SYSTEM  IMPORT ADDRESS;
  1435. X
  1436. XPROCEDURE NewHandle(): ADDRESS;
  1437. X
  1438. XPROCEDURE DisposeHandle(Item: ADDRESS);
  1439. X
  1440. XPROCEDURE DisposeAll();
  1441. X
  1442. XEND HandleCollection.
  1443. END_OF_FILE
  1444. if test 721 -ne `wc -c <'HandleCollection.def'`; then
  1445.     echo shar: \"'HandleCollection.def'\" unpacked with wrong size!
  1446. fi
  1447. # end of 'HandleCollection.def'
  1448. fi
  1449. if test -f 'HandleCollection.mod' -a "${1}" != "-c" ; then 
  1450.   echo shar: Will not clobber existing file \"'HandleCollection.mod'\"
  1451. else
  1452. echo shar: Extracting \"'HandleCollection.mod'\" \(2997 characters\)
  1453. sed "s/^X//" >'HandleCollection.mod' <<'END_OF_FILE'
  1454. XIMPLEMENTATION MODULE HandleCollection;
  1455. X
  1456. X(* Product: Incremental Storage Manager
  1457. X
  1458. X   Version: 1.0
  1459. X
  1460. X   Author:
  1461. X        Daniel B. Hankins
  1462. X        143 Montgomery Street
  1463. X        Poughkeepsie, NY 12601
  1464. X        dan-hankins@cup.portal.com
  1465. X
  1466. X   Creation Date: 1989
  1467. X
  1468. X   Release  Date: November 21, 1989
  1469. X
  1470. X   Notice of Intellectual Property:
  1471. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  1472. X   this program and all its parts in the public domain, under the definitions
  1473. X   and restrictions of United States law.
  1474. X
  1475. X   History of Revisions:
  1476. X        None yet.
  1477. X*)
  1478. X
  1479. XFROM SYSTEM  IMPORT ADDRESS, TSIZE, ADR;
  1480. XFROM Storage IMPORT ALLOCATE, DEALLOCATE;
  1481. X
  1482. XIMPORT DynamicItem;
  1483. XIMPORT FreeHandle;
  1484. X
  1485. XCONST
  1486. X  NumberOfHandlesInBlock = 255;
  1487. X
  1488. XTYPE
  1489. X  HandleBlockPtr = POINTER TO HandleBlock;
  1490. X  HandleBlock = RECORD
  1491. X                  Next: HandleBlockPtr;
  1492. X                  Contents: ARRAY[1..NumberOfHandlesInBlock]
  1493. X                            OF DynamicItem.Object;
  1494. X                END;
  1495. X
  1496. XVAR
  1497. X  FirstFreeHandle:      FreeHandle.Object;
  1498. X  CurrentHandleInBlock: ADDRESS;
  1499. X  CurrentHandlesLeft:   CARDINAL;
  1500. X  FirstBlock:           HandleBlockPtr;
  1501. X
  1502. XPROCEDURE NewHandle(): ADDRESS;
  1503. XVAR
  1504. X  NewItemHandle: DynamicItem.Object;
  1505. X  NewBlock:      HandleBlockPtr;
  1506. XBEGIN
  1507. X  IF NOT(FreeHandle.Nil(FirstFreeHandle)) THEN
  1508. X    NewItemHandle   := DynamicItem.Object(FirstFreeHandle);
  1509. X    FirstFreeHandle := FreeHandle.Next(FirstFreeHandle);
  1510. X    RETURN ADDRESS(NewItemHandle);
  1511. X  END;
  1512. X
  1513. X  IF CurrentHandlesLeft > 0 THEN
  1514. X    NewItemHandle := DynamicItem.Object(CurrentHandleInBlock);
  1515. X    CurrentHandleInBlock :=
  1516. X      ADDRESS(LONGCARD(CurrentHandleInBlock) + TSIZE(DynamicItem.Object));
  1517. X    CurrentHandlesLeft := CurrentHandlesLeft - 1;
  1518. X    RETURN ADDRESS(NewItemHandle);
  1519. X  ELSE
  1520. X    ALLOCATE(NewBlock, TSIZE(HandleBlock));
  1521. X    IF NewBlock = NIL THEN
  1522. X      RETURN NIL;
  1523. X    END;
  1524. X    NewBlock^.Next := FirstBlock;
  1525. X    FirstBlock := NewBlock;
  1526. X    NewItemHandle := DynamicItem.Object(ADR(NewBlock^.Contents));
  1527. X    CurrentHandleInBlock :=
  1528. X      ADDRESS(LONGCARD(NewItemHandle) + TSIZE(DynamicItem.Object));
  1529. X    CurrentHandlesLeft := NumberOfHandlesInBlock - 1;
  1530. X    RETURN ADDRESS(NewItemHandle);
  1531. X  END;
  1532. XEND NewHandle;
  1533. X
  1534. XPROCEDURE DisposeHandle(Item: ADDRESS);
  1535. XVAR
  1536. X  TempItem: POINTER TO FreeHandle.Object;
  1537. XBEGIN
  1538. X  TempItem  := Item;
  1539. X  TempItem^ := FirstFreeHandle;
  1540. X  FirstFreeHandle := FreeHandle.Object(Item);
  1541. XEND DisposeHandle;
  1542. X
  1543. X
  1544. XPROCEDURE DisposeAll();
  1545. XVAR
  1546. X  CurrentBlock, Temp: HandleBlockPtr;
  1547. XBEGIN
  1548. X  CurrentBlock := FirstBlock;
  1549. X  LOOP
  1550. X    IF CurrentBlock = NIL THEN
  1551. X      EXIT;
  1552. X    END;
  1553. X    Temp := CurrentBlock^.Next;
  1554. X    DEALLOCATE(CurrentBlock, TSIZE(HandleBlock));
  1555. X    CurrentBlock := Temp;
  1556. X  END;
  1557. X  FirstFreeHandle      := FreeHandle.NilObject();
  1558. X  CurrentHandleInBlock := NIL;
  1559. X  CurrentHandlesLeft   := 0;
  1560. X  FirstBlock           := NIL;
  1561. XEND DisposeAll;
  1562. X
  1563. X
  1564. XBEGIN
  1565. X  FirstFreeHandle      := FreeHandle.NilObject();
  1566. X  CurrentHandleInBlock := NIL;
  1567. X  CurrentHandlesLeft   := 0;
  1568. X  FirstBlock           := NIL;
  1569. XEND HandleCollection.
  1570. END_OF_FILE
  1571. if test 2997 -ne `wc -c <'HandleCollection.mod'`; then
  1572.     echo shar: \"'HandleCollection.mod'\" unpacked with wrong size!
  1573. fi
  1574. # end of 'HandleCollection.mod'
  1575. fi
  1576. if test -f 'README' -a "${1}" != "-c" ; then 
  1577.   echo shar: Will not clobber existing file \"'README'\"
  1578. else
  1579. echo shar: Extracting \"'README'\" \(5162 characters\)
  1580. sed "s/^X//" >'README' <<'END_OF_FILE'
  1581. XPRODUCT: Incremental Storage Manager
  1582. X
  1583. X
  1584. XVERSION: 1.0
  1585. X
  1586. X
  1587. XAUTHOR:
  1588. X     Daniel B. Hankins
  1589. X     143 Montgomery Street
  1590. X     Poughkeepsie, NY 12601
  1591. X     dan-hankins@cup.portal.com
  1592. X
  1593. X
  1594. XCREATION DATE: 1989
  1595. X
  1596. X
  1597. XRELEASE  DATE: November 21, 1989
  1598. X
  1599. X
  1600. XNOTICE OF INTELLECTUAL PROPERTY:
  1601. X     This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  1602. Xthis program and all its parts in the public domain, under the definitions
  1603. Xand restrictions of United States law.
  1604. X
  1605. X
  1606. XHISTORY OF REVISIONS:
  1607. X     None yet.
  1608. X
  1609. X
  1610. XFILE DISTRIBUTION:
  1611. X     README            FreeHandle.def
  1612. X     Build.Rexx            FreeHandle.mod
  1613. X     DynamicItem.def        HandleCollection.def
  1614. X     DynamicItem.mod        HandleCollection.mod
  1615. X     DynItem.def        Storage.def
  1616. X     DynItem.mod        Storage.mod
  1617. X     DynItemList.def        WordAlign.def
  1618. X     DynItemList.mod        WordAlign.mod
  1619. X     DynTest.mod
  1620. X
  1621. X
  1622. XWHAT IT CAN DO FOR YOU:
  1623. X
  1624. X     This set of modules constitutes a storage manager with garbage
  1625. Xcollection for Modula-2 programs.  It is written in TDI Modula-2 for the
  1626. XAmiga, but should be easily portable to other implementations and
  1627. Xarchitectures.
  1628. X     It uses *INCREMENTAL* garbage collection.  Most garbage collectors
  1629. Xcreate and destroy items willy-nilly until storage is exhausted.  Then they
  1630. Xhold up all other processing while they copy all the in-use items down to
  1631. Xone end of the storage space, thus freeing up the rest of the space for more
  1632. Xitems.
  1633. X     In incremental garbage collection, a few items are copied every time a
  1634. XNew() or Dispose() is done.  This results in overhead which in total is
  1635. Xlarger than that of stop-and-copy methods, but which never causes the
  1636. Xsystem to halt while collection is done.  This is far more suitable for
  1637. Xprograms which require real-time response or close to it.
  1638. X     Also, most storage managers begin with a statically sized storage
  1639. Xspace and allocate from that.  This requires the user to guess before
  1640. Xrunning a program that uses storage management how much storage is going to
  1641. Xbe needed.  Guess too small, and the program aborts.  Guess too large, and
  1642. Xstorage is wasted; other programs can't get space to run in.
  1643. X     This storage manager frees the user from these considerations, and is
  1644. Xa good system citizen in the bargain; it allocates storage in blocks of
  1645. X1K granularity from the operating system, and suballocates from these. 
  1646. XWhenever a block becomes unused, the manager returns it to the system.
  1647. X
  1648. X
  1649. XHOW TO USE IT:
  1650. X
  1651. X     The procedures which perform the services of the manager are defined
  1652. Xin DynamicItem.def.  Build.Rexx contains an ARexx program that will build
  1653. Xthe link and symbol files for the manager in the correct order (provided
  1654. Xyou are using TDI Modula-2).  Just import the procedures and types you want
  1655. Xfrom DynamicItem, and you'll be in business.
  1656. X     The module DynTest.mod is included for those that would like to see it
  1657. Xwork for themselves;  I used it to test the services.
  1658. X
  1659. X
  1660. XBUGS AND CAVEATS:
  1661. X
  1662. X     I've tested the code pretty thoroughly, so I don't think there are any
  1663. Xbugs in it.  If you find some, let me know via snail mail or Usenet mail. 
  1664. XThe addresses are listed at the top of the file.  Or just post in
  1665. Xcomp.sys.amiga;  I read it fairly often.
  1666. X     Performance is probably not all that great;  I organized the code in a
  1667. X*very* object oriented way, in order to make development easier on myself,
  1668. Xand to make the code easier to read for those who'd like to fiddle with it.
  1669. XAs a result, there are many procedures which consist of one, two or a very
  1670. Xfew statements.  This adds considerably to the procedure call overhead.
  1671. X
  1672. X
  1673. XPLANS AND FUTURE FEATURES:
  1674. X
  1675. X* Single-module version
  1676. X     I am in the process of developing a single-module version of this
  1677. Xprogram, with procedures made in-line where appropriate.  That version will
  1678. Xbe distributed along with the object-oriented version.  Future improvements
  1679. Xwill be made in parallel to both versions.
  1680. X
  1681. X* Granularity control
  1682. X     I plan to introduce a variable which the programmer can change to
  1683. Xindicate with what granularity storage should be allocated from the
  1684. Xoperating system.  The minimum granularity, 1K, is hard-wired into the code
  1685. Xat present.  The programmer will be able to change this to 2K or 4K or 37K
  1686. Xor whatever.
  1687. X
  1688. X* Last-ditch stop-and-copy
  1689. X     I plan to add code which handles the eventuality where no more storage
  1690. Xcan be gotten from the operating system, but not all unused space has been
  1691. Xreclaimed from existing storage blocks.  The new code will attempt to
  1692. Xrearrange items in the existing blocks in order to make room for the new
  1693. Xitem.  Currently the code checks existing blocks for unused space.  If it
  1694. Xcannot find what it needs there, then it attempts to allocate storage from
  1695. Xthe operating system.  If that fails, NIL is returned.  The new code will
  1696. Xadd another level of attempt.
  1697. X     The new feature will be able to be switched on and off by means of a
  1698. Xcontrol variable.
  1699. X
  1700. X
  1701. XTHE LAST WORD:
  1702. X
  1703. X     I hope this is of use to Modula-2 programmers.  Send comments, kudos,
  1704. Xinsults, gifts, and flames to the addresses listed at the top of this file.
  1705. XShare and Enjoy!
  1706. X
  1707. X
  1708. XTHE WORD AFTER THE LAST WORD:
  1709. X
  1710. X     "Darrell suspected someone had once again slipped him a spoon with the
  1711. Xconcave side reversed."
  1712. X     - Gary Larson, The Far Side
  1713. END_OF_FILE
  1714. if test 5162 -ne `wc -c <'README'`; then
  1715.     echo shar: \"'README'\" unpacked with wrong size!
  1716. fi
  1717. # end of 'README'
  1718. fi
  1719. if test -f 'Storage.def' -a "${1}" != "-c" ; then 
  1720.   echo shar: Will not clobber existing file \"'Storage.def'\"
  1721. else
  1722. echo shar: Extracting \"'Storage.def'\" \(1135 characters\)
  1723. sed "s/^X//" >'Storage.def' <<'END_OF_FILE'
  1724. XDEFINITION MODULE Storage;
  1725. X
  1726. X(* Product: Incremental Storage Manager
  1727. X
  1728. X   Version: 1.0
  1729. X
  1730. X   Author:
  1731. X        Daniel B. Hankins
  1732. X        143 Montgomery Street
  1733. X        Poughkeepsie, NY 12601
  1734. X        dan-hankins@cup.portal.com
  1735. X
  1736. X   Creation Date: 1989
  1737. X
  1738. X   Release  Date: November 21, 1989
  1739. X
  1740. X   Notice of Intellectual Property:
  1741. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  1742. X   this program and all its parts in the public domain, under the definitions
  1743. X   and restrictions of United States law.
  1744. X
  1745. X   History of Revisions:
  1746. X        None yet.
  1747. X*)
  1748. X
  1749. XFROM SYSTEM IMPORT ADDRESS;
  1750. X
  1751. XPROCEDURE ALLOCATE(VAR addr: ADDRESS; amount: LONGCARD);
  1752. X(* allocate storage from the operating system.
  1753. X
  1754. X   addr: returns where the memory portion was allocated, word aligned.
  1755. X         returns NIL if no block of the requisite size could be found.
  1756. X   amount: the number of bytes to allocate, will be a word multiple.
  1757. X*)
  1758. X
  1759. XPROCEDURE DEALLOCATE(VAR addr: ADDRESS; amount: LONGCARD);
  1760. X(* return storage to the operating system.
  1761. X
  1762. X   addr: the portion of memory returned by ALLOCATE.
  1763. X   amount: the size of the block given to ALLOCATE.
  1764. X*)
  1765. X
  1766. XEND Storage.
  1767. END_OF_FILE
  1768. if test 1135 -ne `wc -c <'Storage.def'`; then
  1769.     echo shar: \"'Storage.def'\" unpacked with wrong size!
  1770. fi
  1771. # end of 'Storage.def'
  1772. fi
  1773. if test -f 'Storage.mod' -a "${1}" != "-c" ; then 
  1774.   echo shar: Will not clobber existing file \"'Storage.mod'\"
  1775. else
  1776. echo shar: Extracting \"'Storage.mod'\" \(781 characters\)
  1777. sed "s/^X//" >'Storage.mod' <<'END_OF_FILE'
  1778. XIMPLEMENTATION MODULE Storage;
  1779. X
  1780. XFROM SYSTEM IMPORT ADDRESS, NULL;
  1781. XIMPORT Memory;
  1782. X
  1783. XPROCEDURE ALLOCATE(VAR addr: ADDRESS; amount: LONGCARD);
  1784. X  (* allocate a portion of memory - return 0 if no memory available.
  1785. X
  1786. X     addr: returns where the memory portion was allocated, word aligned.
  1787. X     amount: the number of bytes to allocate, will be a word multiple. *)
  1788. XBEGIN
  1789. X  addr := Memory.AllocMem(amount, Memory.MemReqSet{Memory.MemClear});
  1790. X
  1791. X  IF addr = NULL
  1792. X  THEN
  1793. X    addr := NIL;
  1794. X  END;
  1795. XEND ALLOCATE;
  1796. X
  1797. XPROCEDURE DEALLOCATE(VAR addr: ADDRESS; amount: LONGCARD);
  1798. X  (* return a portion of memory to the heap.
  1799. X
  1800. X     addr: the portion of memory returned by ALLOCATE.
  1801. X     amount: the size of the block given to ALLOCATE. *)
  1802. XBEGIN
  1803. X  Memory.FreeMem(addr, amount);
  1804. XEND DEALLOCATE;
  1805. X
  1806. XEND Storage.
  1807. END_OF_FILE
  1808. if test 781 -ne `wc -c <'Storage.mod'`; then
  1809.     echo shar: \"'Storage.mod'\" unpacked with wrong size!
  1810. fi
  1811. # end of 'Storage.mod'
  1812. fi
  1813. if test -f 'WordAlign.def' -a "${1}" != "-c" ; then 
  1814.   echo shar: Will not clobber existing file \"'WordAlign.def'\"
  1815. else
  1816. echo shar: Extracting \"'WordAlign.def'\" \(630 characters\)
  1817. sed "s/^X//" >'WordAlign.def' <<'END_OF_FILE'
  1818. XDEFINITION MODULE WordAlign;
  1819. X
  1820. X(* Product: Incremental Storage Manager
  1821. X
  1822. X   Version: 1.0
  1823. X
  1824. X   Author:
  1825. X        Daniel B. Hankins
  1826. X        143 Montgomery Street
  1827. X        Poughkeepsie, NY 12601
  1828. X        dan-hankins@cup.portal.com
  1829. X
  1830. X   Creation Date: 1989
  1831. X
  1832. X   Release  Date: November 21, 1989
  1833. X
  1834. X   Notice of Intellectual Property:
  1835. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  1836. X   this program and all its parts in the public domain, under the definitions
  1837. X   and restrictions of United States law.
  1838. X
  1839. X   History of Revisions:
  1840. X        None yet.
  1841. X*)
  1842. X
  1843. XPROCEDURE WordAlign(Argument: LONGCARD): LONGCARD;
  1844. X
  1845. XEND WordAlign.
  1846. END_OF_FILE
  1847. if test 630 -ne `wc -c <'WordAlign.def'`; then
  1848.     echo shar: \"'WordAlign.def'\" unpacked with wrong size!
  1849. fi
  1850. # end of 'WordAlign.def'
  1851. fi
  1852. if test -f 'WordAlign.mod' -a "${1}" != "-c" ; then 
  1853.   echo shar: Will not clobber existing file \"'WordAlign.mod'\"
  1854. else
  1855. echo shar: Extracting \"'WordAlign.mod'\" \(693 characters\)
  1856. sed "s/^X//" >'WordAlign.mod' <<'END_OF_FILE'
  1857. XIMPLEMENTATION MODULE WordAlign;
  1858. X
  1859. X(* Product: Incremental Storage Manager
  1860. X
  1861. X   Version: 1.0
  1862. X
  1863. X   Author:
  1864. X        Daniel B. Hankins
  1865. X        143 Montgomery Street
  1866. X        Poughkeepsie, NY 12601
  1867. X        dan-hankins@cup.portal.com
  1868. X
  1869. X   Creation Date: 1989
  1870. X
  1871. X   Release  Date: November 21, 1989
  1872. X
  1873. X   Notice of Intellectual Property:
  1874. X        This material is *NOT COPYRIGHTED*.  By this notice, I hereby place
  1875. X   this program and all its parts in the public domain, under the definitions
  1876. X   and restrictions of United States law.
  1877. X
  1878. X   History of Revisions:
  1879. X        None yet.
  1880. X*)
  1881. X
  1882. XPROCEDURE WordAlign(Argument: LONGCARD): LONGCARD;
  1883. XBEGIN
  1884. X  RETURN Argument + (Argument MOD 2);
  1885. XEND WordAlign;
  1886. X
  1887. XEND WordAlign.
  1888. END_OF_FILE
  1889. if test 693 -ne `wc -c <'WordAlign.mod'`; then
  1890.     echo shar: \"'WordAlign.mod'\" unpacked with wrong size!
  1891. fi
  1892. # end of 'WordAlign.mod'
  1893. fi
  1894. echo shar: End of archive 1 \(of 1\).
  1895. cp /dev/null ark1isdone
  1896. MISSING=""
  1897. for I in 1 ; do
  1898.     if test ! -f ark${I}isdone ; then
  1899.     MISSING="${MISSING} ${I}"
  1900.     fi
  1901. done
  1902. if test "${MISSING}" = "" ; then
  1903.     echo You have the archive.
  1904.     rm -f ark[1-9]isdone
  1905. else
  1906.     echo You still need to unpack the following archives:
  1907.     echo "        " ${MISSING}
  1908. fi
  1909. ##  End of shell archive.
  1910. exit 0
  1911. -- 
  1912. Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
  1913. Mail comments to the moderator at <amiga-request@cs.odu.edu>.
  1914. Post requests for sources, and general discussion to comp.sys.amiga.
  1915.